/*
 *  Copyright (C) 2011 Rémi Thebault
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef PRINTDIALOG_H
#define PRINTDIALOG_H

#include <QDialog>
#include <QGraphicsScene>

#include "pcchild.h"


class QPrinter;

class PrintScene;
class TaskTreeView;
class GanttScene;

namespace Ui {
class PrintDialog;
}

class PrintDialog : public QDialog, public PCChild
{
    Q_OBJECT

public:

    static void handlePrintRequest(ProCycle *app);

protected:
    explicit PrintDialog(ProCycle *app, QPrinter *printer, PrintScene *scene);
  ~PrintDialog();


protected slots:
    void printerTypeChanged();
    void printerChanged();

    void rangeChanged();
    void layoutChanged();
    void optionChanged();


private:
    Ui::PrintDialog *ui;

    QPrinter *m_printer;
    PrintScene *m_printScene;
};




class PrintScene : public QGraphicsScene {

    Q_OBJECT

public:

    PrintScene (QObject *parent, ProCycle *app, QPrinter *printer);
    ~PrintScene();

    bool setShowTable(bool show) {
        m_showTable = show;
    }
    bool setShowSimogram(bool show) {
        m_showSimogram = show;
    }
    bool setShowCriticalPath(bool show) {
        m_showCriticalPath = show;
    }
    bool setShowFloat(bool show) {
        m_showFloat = show;
    }
    bool setShowTaskName(bool show) {
        m_showTaskName = show;
    }
    bool setShowOverlap(bool show) {
        m_showOverlap = show;
    }


protected:
    void drawForeground(QPainter *painter, const QRectF &rect);

private:

    QPrinter *m_printer;

    TaskTreeView *m_treeView;
    GanttScene *m_ganttScene;

    float m_treeWidth;

    bool m_showTable;
    bool m_showSimogram;
    bool m_showCriticalPath;
    bool m_showFloat;
    bool m_showTaskName;
    bool m_showOverlap;
};

#endif // PRINTDIALOG_H
